/***     
 * SP_FIVE_THREE_DEOUBLE: 9, // 三条一对
 */

var CardGroupType = require('./CardGroupType');
var FindSameCardValueTool = require('./../FindTool/FindSameCardValueTool');
var _ = require('./../Underscore');
var CardType = require('./../CardType');
var CardTool = require('./../CardTool');
var FindShunZiTool = require('../FindTool/FindShunZiTool');
var FindPairsTool = require('./../FindTool/FindPairsTool');
var GroupThreeAndAPairs = module.exports = {};


GroupThreeAndAPairs.getName = function() {
    return '三条一对';
};

GroupThreeAndAPairs.getType = function() {
    return CardGroupType.SP_FIVE_THREE_DEOUBLE;
};

/**三条一对 */
GroupThreeAndAPairs.getMoreResult = function(_cardInfoList) {
    var resultInfo = FindSameCardValueTool.getResult(_cardInfoList, 3);
    var findGroupMore = [];

    if (resultInfo.isFind) {
        _.each(resultInfo.findGroup, function(singleGroup) {
            var findGroup = singleGroup;
            var otherGroup = _.difference(_cardInfoList, findGroup);
            var tmpResult = FindPairsTool.getResult(otherGroup, 1);
            if (tmpResult.isFind) {
                findGroup.push(tmpResult.findGroup[0]);
                findGroup = _.flatten(findGroup);
                otherGroup = _.difference(_cardInfoList, findGroup);
                findGroupMore.push({
                    findGroup: findGroup,
                    otherGroup: otherGroup
                })
            }
        });
    }
    var result = {
        isFind: _.size(findGroupMore) > 0,
        findGroupMore: findGroupMore
    }
    CardTool.LogResult(result, this.getName());
    return result;
};